home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Freeware / CheckDisk / Src / ffs.h < prev    next >
C/C++ Source or Header  |  2002-10-28  |  7KB  |  243 lines

  1. /*
  2. **    $RCSfile: ffs.h,v $
  3. **    $Filename: ffs.h $
  4. **    $Revision: 0.1 $
  5. **    $Date: $
  6. **
  7. **    Defines for FFS on-disk Block structure (version 0.1)
  8. **
  9. */
  10.  
  11. /* Block Types */
  12.  
  13. #define    T_SHORT        0x2    /* header blocks, whatever object */
  14. #define    T_DATA        0x8    /* OFS data blocks */
  15. #define    T_LIST        0x10    /* file extension blocks */
  16. #define T_DIRLIST    0x21    /* directory cache blocks */
  17.  
  18. /* Secondary Block Types for filesystem objects */
  19.  
  20. #define    ST_ROOT        1    /* the filesystem root directory */
  21. #define ST_USERDIR    2    /* user created subdirectories */
  22. #define ST_SOFTLINK    3    /* soft (symbolic) links */
  23. #define    ST_LINKDIR    4    /* hard link to directory */
  24. #define    ST_FILE        -3    /* regular file */
  25. #define    ST_LINKFILE    -4    /* hard link to file */
  26.  
  27. /* Offsets for longword fields in filesystem blocks (negative offsets are relative to the size
  28.    of the block) */
  29.  
  30. /* Root Directory */
  31. #define    ROOT_TYPE        0
  32. #define    ROOT_HASHSIZE        3
  33. #define    ROOT_CHECKSUM        5
  34. #define    ROOT_HASHTABLE        6
  35. #define    ROOT_BITMAPFLAG        -50
  36. #define ROOT_BITMAPBLOCKS    -49
  37. #define    ROOT_BITMAPEXT        -24
  38. #define    ROOT_DAYS        -23
  39. #define    ROOT_MINS        -22
  40. #define    ROOT_TICKS        -21
  41. #define    ROOT_DISKNAME        -20
  42. #define    ROOT_VOLUMEDAYS        -10
  43. #define ROOT_VOLUMEMINS        -9
  44. #define    ROOT_VOLUMETICKS    -8
  45. #define    ROOT_CREATIONDAYS    -7
  46. #define ROOT_CREATIONMINS    -6
  47. #define    ROOT_CREATIONTICKS    -5
  48. #define    ROOT_DIRCACHE        -2
  49. #define    ROOT_SECTYPE        -1
  50.  
  51. /* User Directory */
  52. #define UDIR_TYPE        0
  53. #define    UDIR_OWNKEY        1
  54. #define    UDIR_HASHSIZE        3
  55. #define    UDIR_CHECKSUM        5
  56. #define    UDIR_HASHTABLE        6
  57. #define UDIR_OWNER        -49
  58. #define    UDIR_PROTECTION        -48
  59. #define UDIR_COMMENT        -46
  60. #define UDIR_DAYS        -23
  61. #define    UDIR_MINS        -22
  62. #define    UDIR_TICKS        -21
  63. #define    UDIR_NAME        -20
  64. #define UDIR_LINK        -11
  65. #define    UDIR_LINKBACK        -10
  66. #define    UDIR_HASHCHAIN        -4
  67. #define    UDIR_PARENT        -3
  68. #define UDIR_DIRCACHE        -2
  69. #define UDIR_SECTYPE        -1
  70.  
  71. /* File Header */
  72. #define    FILE_TYPE        0
  73. #define    FILE_OWNKEY        1
  74. #define FILE_BLOCKCOUNT        2
  75. #define FILE_FIRSTBLOCK        4
  76. #define FILE_CHECKSUM        5
  77. #define FILE_DATABLOCKS        6
  78. #define    FILE_DATABLOCK1        -51
  79. #define FILE_OWNER        -49
  80. #define FILE_PROTECTION        -48
  81. #define FILE_BYTESIZE        -47
  82. #define FILE_COMMENT        -46
  83. #define FILE_DAYS        -23
  84. #define FILE_MINS        -22
  85. #define FILE_TICKS        -21
  86. #define FILE_NAME        -20
  87. #define    FILE_LINKBACK        -10
  88. #define FILE_HASHCHAIN        -4
  89. #define FILE_PARENT        -3
  90. #define FILE_EXTENSION        -2
  91. #define FILE_SECTYPE        -1
  92.  
  93. /* Hard Links */
  94. #define HLINK_TYPE        0
  95. #define HLINK_OWNKEY        1
  96. #define HLINK_CHECKSUM        5
  97. #define HLINK_OWNER        -49
  98. #define HLINK_PROTECTION    -48
  99. #define HLINK_COMMENT        -46
  100. #define HLINK_DAYS        -23
  101. #define HLINK_MINS        -22
  102. #define HLINK_TICKS        -21
  103. #define HLINK_NAME        -20
  104. #define HLINK_ORIGINAL        -11
  105. #define HLINK_LINKCHAIN        -10
  106. #define HLINK_HASHCHAIN        -4
  107. #define HLINK_PARENT        -3
  108. #define HLINK_SECTYPE        -1
  109.  
  110. /* Soft Links */
  111. #define SLINK_TYPE        0
  112. #define SLINK_OWNKEY        1
  113. #define SLINK_CHECKSUM        5
  114. #define SLINK_OBJECTNAME    6
  115. #define SLINK_OWNER        -49
  116. #define SLINK_PROTECTION    -48
  117. #define SLINK_COMMENT        -46
  118. #define SLINK_DAYS        -23
  119. #define SLINK_MINS        -22
  120. #define SLINK_TICKS        -21
  121. #define SLINK_NAME        -20
  122. #define SLINK_HASHCHAIN        -4
  123. #define SLINK_PARENT        -3
  124. #define SLINK_SECTYPE        -1
  125.  
  126. /* File Extension Blocks */
  127. #define    FEXT_TYPE        0
  128. #define FEXT_OWNKEY        1
  129. #define FEXT_BLOCKCOUNT        2
  130. #define    FEXT_CHECKSUM        5
  131. #define FEXT_DATABLOCKS        6
  132. #define    FEXT_DATABLOCK1        -51
  133. #define    FEXT_PARENT        -3
  134. #define FEXT_EXTENSION        -2
  135. #define FEXT_SECTYPE        -1
  136.  
  137. /* OFS Data Blocks */
  138. #define    DATA_TYPE        0
  139. #define DATA_HEADERKEY        1
  140. #define DATA_SEQNUM        2
  141. #define    DATA_SIZE        3
  142. #define    DATA_NEXTBLOCK        4
  143. #define DATA_CHECKSUM        5
  144. #define DATA_DATABYTES        6
  145.  
  146. /* DirCache Blocks */
  147. #define    DCACHE_TYPE        0
  148. #define DCACHE_OWNKEY        1
  149. #define DCACHE_PARENT        2
  150. #define DCACHE_NUMENTRIES    3
  151. #define DCACHE_NEXTBLOCK    4
  152. #define DCACHE_CHECKSUM        5
  153. #define DCACHE_DIRENTRIES    6
  154.  
  155. /* DirCache entries */
  156. struct ListEntry
  157. { ULONG Key;
  158.   ULONG Size;
  159.   ULONG Protection;
  160.   ULONG OwnerXID;
  161.   UWORD Days;
  162.   UWORD Min;
  163.   UWORD Tick;
  164.   UBYTE Type;
  165.   UBYTE FileNameLength;
  166. };
  167.  
  168. /* BitMap Blocks */
  169. #define BITMAP_CHECKSUM        0
  170. #define BITMAP_BITMAPDATA    1
  171.  
  172. /* BitMap Extension Blocks */
  173. #define BEXT_POINTERS        0
  174. #define BEXT_EXTENSION        -1
  175.  
  176. /* Boot Block */
  177. #define    BOOT_ID            0
  178. #define BOOT_CHECKSUM        1
  179. #define BOOT_DOSBLOCK        2
  180. #define BOOT_CODE        3
  181.  
  182. /* Error codes for FFS support functions */
  183.  
  184. #define ERR_BADTYPE    -129
  185. #define ERR_BADSECTYPE    -130
  186. #define    ERR_BADCHKSUM    -131
  187. #define ERR_BLKCORRUPT    -132
  188. #define ERR_INVBLKNUM    -133
  189.  
  190. /* struct DiskDevice used by FFS support functions */
  191.  
  192. #define DNAME_SIZE    32
  193.  
  194. struct DiskDevice
  195. {    UBYTE    dd_DeviceName[DNAME_SIZE];    /* Name of exec device */
  196.     ULONG    dd_DeviceUnit;            /* Device unit number */
  197.     ULONG    dd_DeviceFlags;            /* OpenDevice flags */
  198.     ULONG    dd_SectorSize;            /* Physical sector size in bytes */
  199.     ULONG    dd_SectorsPerBlock;        /* Number of sectors per logical filesystem block */
  200.     ULONG    dd_SectorsPerTrack;        /* Number of sectors per track */
  201.     ULONG    dd_Surfaces;            /* Number of surfaces (tracks per cylinder) */
  202.     ULONG    dd_LowCyl;            /* First cylinder of the partition */
  203.     ULONG    dd_HighCyl;            /* Last cylinder of the partition */
  204.     ULONG    dd_BufMemType;            /* Type of memory for data buffers */
  205.     ULONG    dd_Flags;            /* Special flags */
  206.     ULONG    dd_MaxTransfer;            /* Maximum Transfer Size */
  207.     ULONG    dd_DOSType;            /* Filesystem DOSType */
  208.     ULONG    dd_Reserved;            /* Reserved Blocks (at least 1) */
  209.     ULONG    dd_HighKey;            /* Highest block number (filled by initFFS) */
  210.     ULONG    dd_RootKey;            /* Root block number (filled by initFFS) */
  211.     ULONG    dd_SectorsPerCyl;        /* Number of sectors per cylinder (filled by initFFS) */
  212.     UWORD    dd_BlockSizeL;            /* Logical block size in longwords (filled by initFFS) */
  213.     UWORD    dd_CylStep;            /* Number of cylinders to read at once */
  214. };
  215.  
  216. #define DDFB_VERBOSE    0        /* Output more information */
  217. #define    DDFB_CUSTOM    1        /* Not scanning a known partition */
  218. #define    DDFB_DO64BIT    2        /* Use 64bit commands */
  219.  
  220. #define DDFF_VERBOSE    (1L << DDFB_VERBOSE)
  221. #define    DDFF_CUSTOM    (1L << DDFB_CUSTOM)
  222. #define    DDFF_DO64BIT    (1L << DDFB_DO64BIT)
  223.  
  224. /* Functions in FFSsupport.c */
  225.  
  226. int initFFS(void);
  227. ULONG *readblock(ULONG KeyID);
  228. int writeblock(ULONG *buffer, ULONG KeyID);
  229. int checkblock(ULONG *buffer, ULONG KeyID, int type, int sectype);
  230. int checkbmblock(ULONG *buffer);
  231. ULONG *readbitmap(ULONG *rootblock);
  232. ULONG findfreeblock(ULONG *bitmap, ULONG StartKey);
  233. ULONG findcontigfreeblocks(ULONG *bitmap, int numblocks);
  234. BOOL allocblock(ULONG *bitmap, ULONG KeyID);
  235. BOOL freeblock(ULONG *bitmap, ULONG KeyID);
  236. BOOL isfreeblock(ULONG *bitmap, ULONG KeyID);
  237. ULONG *initheader(ULONG KeyId, ULONG ParentKey, int type, int sectype, STRPTR name);
  238. void sumblock(ULONG *buffer);
  239. ULONG hashname(STRPTR name);
  240. void clearblockptrs(ULONG *header);
  241. ULONG gethashchain(ULONG *dirblock, ULONG *headerblock);
  242. int hashlink(ULONG *dirblock, ULONG *headerblock);
  243.